<!DOCTYPE html>
<html ng-app='thirdApp'>
	<head>
		<meta charset="UTF-8">
		<title>重置密码</title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../css/t-login.css"/>
		<link rel="stylesheet" type="text/css" href="../css/nava.css"/>
		<link rel="stylesheet" type="text/css" href="../css/foot.css"/>
		<script type="text/javascript" src="../js/angular.min.js"></script>
		<script type="text/javascript" src="../js/angular-route.min.js"></script>
		<script type="text/javascript" src="../js/jquery-2.2.4.min.js"></script>
	</head>
	<body>
		<div ng-include="'nava.html'"></div>
		<!--头-->
		<div class="logo-out">
			<div>
				<img src="../img/t-logo.png"/>
				<p>找回密码</p>
			</div>
		</div>
		<!--背景登录-->
		<div class="bg-content">
			<div class="login-div clearfix">
				<!--免费注册-->
				<div class="border-out">
					<div>
						<p>礼拜五会员</p>
						<p>免费注册</p>
					</div>
				</div>
				<div class="reset-right">
					<div class="doad-div clearfix">
						<span>重置密码</span>
					</div>
					<div class="load-ph">
						<input type="text" id="t-loadtext" placeholder="请输入手机号" />
						<img class="t-loadimg" src="../img/t-phone-true.png" alt=""/>
						<div class="pas-wrong">
							<img src="../img/t-wrong-phone.png" alt=""/>
							<span>手机号码不正确，请重新输入</span>
						</div>
					</div>
					<div class="resetdiv"><input type="text"  class="resetIn" placeholder="验证码"/><div class="yanimg"></div><span class="spanbtn">看不清换一张</span></div>
					<input class="t-cl" type="password" id="resetext" placeholder="请输入密码(6-20位号码字符)"/>
					<input class="t-cl" type="password"  id="resetext1" placeholder="请再次输入密码确认"/>
					
					<div class="t-resetnum">
						<input type="text" class="phonethr" placeholder="手机验证码" /><span class="resetgetnum">获取验证码</span>
					</div>
					<div class="resetBtn">提交</div>
				</div>
				
			</div>
		</div>
		<div ng-include="'foot.html'"></div>
	</body>
	<script type="text/javascript">
		var app = angular.module('thirdApp',['ngRoute']);
		var bubu = false;
		
		
		app.controller('navctrl',function($scope){
			$('.pleaselogin').html(localStorage.getItem("name"));
			//我的订单
			$('.ding1').click(function(){
				if ($('.t-tui').text()=='退出') {
					window.location='personalcenter.html#/buy';
				}else{
					window.location='t-loadimg.html';
				};
				
			});
			//我的消息
			$('.ding2').click(function(){
				if ($('.t-tui').text()=='退出') {
					window.location='personalcenter.html#/msg';
				}else{
					window.location='t-loadimg.html';
				};
				
			});	
			//我的商家
			$('.ding3').click(function(){
				if (bubu) {
					window.location='personalcenter.html#/store';
				}else{
					window.location='t-loadimg.html';
				};
				
			});
			localStorage.a ='退出';
			localStorage.b ='请登录';
			$('.t-tui').click(function(){
				if (bubu){
					$('.pleaselogin').html('');
					$(this).html(localStorage.getItem('b'));
					bubu = false;
				}else{
					$(this).html(localStorage.getItem('a'));
					window.location='t-loadimg.html';
					localStorage.clear()
					
					bubu = true;
				}	
			})
		})
		
		
		var yanimg = document.getElementsByClassName('yanimg')
		var arr = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
            'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
        var arr1 = []
		var donum;
		var deg;
		
		var arr2 =[];
//		var obj ={}
		var a='';
		var b='';
		
		var phone = document.getElementById('t-loadtext');
				//手机验证码
				$('.resetgetnum').click(function(){
					for (var i = 0;i<6;i++) {
						b+=Math.floor(Math.random()*9)
						if (/^1[34578]\d{9}$/.test($('#t-loadtext').val())) {
							$('.phonethr').val(b)
						}else(
							 $('.pas-wrong').css({
					         	display:'block'
					         })
						)
						
					}
					b=''
				})
		//验证码
		for (var i = 0;i<4;i++) {
				deg = Math.floor(Math.random()*100-40);
				donum = Math.floor(Math.random()*62);
				arr1.push(arr[donum]) 
				yanimg[0].innerHTML+= "<span>"+arr1[i]+"</span>"
				$('.yanimg span').eq(i).css({
					transform:'rotateZ('+deg+'deg)'
				})
				a+=arr1[i]
				
		}
		arr1=[];
		$('.spanbtn').click(function(){
			a='';
			$('.yanimg').children('span').remove()
			for (var i = 0;i<4;i++) {
				deg = Math.floor(Math.random()*100-40);
				donum = Math.floor(Math.random()*62);
				arr1.push(arr[donum]) 
				yanimg[0].innerHTML+= "<span>"+arr1[i]+"</span>";
				$('.yanimg span').eq(i).css({
					transform:'rotateZ('+deg+'deg)'
				})
				a+=arr1[i]
			}
			console.log(a)
			arr1=[];
		})
		
		phone.oninput = function(){
			 $('.pas-wrong').css({
		         	display:'none'
		         })
			 if(/^1[34578]\d{9}$/.test($('#t-loadtext').val())){
		    		$('.t-loadimg').css({
		    			display:'block'
		    		})
		    	}else{
		    		$('.t-loadimg').css({
		    			display:'none'
		    		})
		    	}
		}
		
		$('.resetBtn').click(function(){
			
			 if(!(/^1[34578]\d{9}$/.test($('#t-loadtext').val()))){ 
		         $('.pas-wrong').css({
		         	display:'block'
		         })
		        return false;
			 
		    }else if($('.resetIn').val()!=a){
		    		alert('验证码输入错误');
		    		return false;
		    }else if($('#resetext').val()==''||$('#resetext1').val()==''){
		    		alert('密码或确认密码不能为空!');
		    		return false;
		    }else if($('#resetext').val()!=$('#resetext1').val()){
		    		alert('两次输入的密码不同');
		    		return false;
		    }else if(!(/^[\w.]{6,20}$/.test($('#resetext').val()))){
		    		alert('密码必须是6~20位字符');
		    		return false;
		    }else if($('.phonethr').val()==''){
		    		alert('手机验证码错误');
		    		return false;
		    }else{

//					alert(1)
					 
					//更改数据
					var obj ={};
					obj.phone = $('#t-loadtext').val();
					obj.pas=$('#resetext').val();
					$.post('../php/data4.php',obj,function(data){
						alert(data);
						if (data=='密码修改成功') {
							
							window.location.href='t-loadimg.html';
								$('#phonetext').val('');
					    			$('#pastext').val('');
					    			$('#pastext1').val('');
					    			$('.inputnum').val('');
					    			$('.get_num').val('');
					    			$('.checkImg').css({
					    				display:'none'
					    			})
						}
						
					})
		    			
		    			
		    }
			
		})
		$('.logo-out div img').click(function(){
			window.location.href='index.html';
		})
	</script>
</html>
